﻿using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AppMachine.Models {
    public class VmTreeNode:BindableBase {
        private string _Name = default(string);
        public string Name {
            get => _Name;
            set { SetProperty(ref _Name, value); }
        }
        private bool _IsSelected = default(bool);
        public bool IsSelected {
            get => _IsSelected;
            set { SetProperty(ref _IsSelected, value); }
        }
        public ObservableCollection<VmTreeNode> Children { get; set; }= new ObservableCollection<VmTreeNode>();

        public static ObservableCollection<VmTreeNode> Nodes { get; set; } = new ObservableCollection<VmTreeNode>();
        static VmTreeNode() {
            VmTreeNode tempChina = new VmTreeNode() {
                Name = "中国"
            };
            VmTreeNode tempAmerica = new VmTreeNode() {
                Name = "美国"
            };
            VmTreeNode tempJapan = new VmTreeNode() {
                Name = "日本"
            };

            VmTreeNode tempChinaBeiJing = new VmTreeNode() {
                Name = "北京"
            };
            VmTreeNode tempChinaShangHai = new VmTreeNode() {
                Name = "上海"
            };
            VmTreeNode tempChinaSichuan = new VmTreeNode() {
                Name = "四川"
            };

            VmTreeNode tempChinaSichuanZiYang = new VmTreeNode() {
                Name = "资阳"
            };
            VmTreeNode tempChinaSichuanChengDu = new VmTreeNode() {
                Name = "成都"
            };
            VmTreeNode tempChinaSichuanMianYang = new VmTreeNode() {
                Name = "绵阳"
            };

            VmTreeNode tempAmericaWashington = new VmTreeNode() {
                Name = "华盛顿"
            };
            VmTreeNode tempAmericaNewYork = new VmTreeNode() {
                Name = "纽约"
            };
            VmTreeNode tempAmericaFrisco = new VmTreeNode() {
                Name = "旧金山"
            };

            VmTreeNode tempJapanTokyo = new VmTreeNode() {
                Name = "东京"
            };
            VmTreeNode tempJapanOsaka = new VmTreeNode() {
                Name = "大阪"
            };
            VmTreeNode tempJapanKobe = new VmTreeNode() {
                Name = "神户"
            };

            Nodes.AddRange(new[] { tempChina, tempJapan, tempAmerica });
            tempChina.Children.AddRange(new[] {tempChinaBeiJing,tempChinaShangHai,tempChinaSichuan});
            tempChinaSichuan.Children.AddRange(new[] { tempChinaSichuanChengDu, tempChinaSichuanMianYang , tempChinaSichuanZiYang });

            tempAmerica.Children.AddRange(new[] { tempAmericaWashington, tempAmericaNewYork, tempAmericaFrisco });
            tempJapan.Children.AddRange(new[] { tempJapanTokyo, tempJapanOsaka, tempJapanKobe });
            
        }

    }
}
